package coolq

import (
	"fmt"
	"regexp"

	"github.com/Mrs4s/MiraiGo/message"
)

// guild自定义回复
func (bot *CQBot) dispatchGuildMessage(guildNane string, guild uint64, channelName string, channelID uint64, nickname string,
	tinyId uint64, m []message.IMessageElement, source MessageSource) {
	msg := ToStringMessage(m, source, true)
	// 收到来自频道 IT界卷王(21029471636646237) 子频道 🤖妹妹同学(开发中)(1350516) 内 Yexk_M(144115218677625282) 的消息: test
	// 收到来自频道 IT界卷王(21029471636646237) 子频道 🍺摸鱼灌水(1300118) 内 Yexk_M(144115218677625282) 的消息: 1
	if guild == 21029471636646237 && channelID == 1300118 {
		// 排除自家
		reg := regexp.MustCompile(`-- from`)
		if !reg.MatchString(msg) {
			eles := make([]message.IMessageElement, 0)
			for _, v := range m {
				eles = append(eles, v)
			}
			eles = append(eles, message.NewText(fmt.Sprintf("\n-- from:%s-%s,name: %s", guildNane, channelName, nickname)))
			bot.SendGroupMessage(318195769, &message.SendingMessage{
				Elements: eles,
			})
		}

	}
}
